/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejemplojavaex;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLista;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLocal;
import mx.edu.itschapala.sistemas.septimo.modelo.Cliente;

/**
 * FXML Controller class
 *
 * @author Estudiante
 */
public class ListarVentasController implements Initializable {

    @FXML
    private AnchorPane ventanaLV;
    @FXML
    private TableView tablaV;
    @FXML
    private TableColumn idV;
    @FXML
    private TableColumn idC;
    @FXML
    private TableColumn nombreC;
    @FXML
    private TableColumn idP;
    @FXML
    private TableColumn nombreP;
    @FXML
    private TableColumn fecha;
    
    private ObservableList lista; 
    
    @FXML
    public void ventanaMenu(){
        try{
            Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
            ventanaLV.getScene().setRoot(root);
        }catch (IOException e){
            System.out.println("Error al cargar la ventana de menu");
        }
        
    }
    @FXML
    public void ventanaRegistroV(){
        try{
            Parent root = FXMLLoader.load(getClass().getResource("RegistrarVenta.fxml"));
            ventanaLV.getScene().setRoot(root);
        }catch (IOException ex){
            System.out.println("Error al cargar la ventana de producto");
        }
        
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        ClienteLnLocal cln = ClienteLnLista.getIsnstnciaC();
        lista= FXCollections.observableArrayList();
        for(Cliente c : cln.cliengetTodos()){
            lista.add(c);
        }
            idV.setCellValueFactory(new PropertyValueFactory("codigo"));
            idC.setCellValueFactory(new PropertyValueFactory("nombre"));
            nombreC.setCellValueFactory(new PropertyValueFactory("precio"));
            idP.setCellValueFactory(new PropertyValueFactory("departamento"));
            nombreP.setCellValueFactory(new PropertyValueFactory("descripcion"));
            fecha.setCellValueFactory(new PropertyValueFactory("descripcion"));
            
        // TODO
    }    
}
